import React, {Component} from 'react'
import MemoryUtil from '../../util/memorizeUtil'
import {Redirect,Route,Switch} from "react-router-dom";
import {Layout }  from 'antd'

import LeftNav from '../../components/leftnav'
import Header from '../../components/header'
import Footer from '../../components/footer'
import Home from '../home/home'
import Category from '../category/category'
import Product from '../product/product'
import Role from '../role/role'
import User from '../user/user'
import Line from '../charts/line'
import Bar from '../charts/bar'
import Pie from '../charts/pie'

const {Sider,Content} = Layout
/* import './index.less'
import {Row,Col} from 'antd'; */

export default class admin extends Component {
  render () {

    if(!(MemoryUtil.user && MemoryUtil.user._id)){
      return <Redirect to='/login'/>
    }
    return (
      <Layout>
        <Sider>
          <LeftNav/>
        </Sider>
        <Layout>
          <Header/>
          <Content style={{margin: 10, background: 'white'}}>
            <Switch>
            <Route path='/home' component={Home}/>
              <Route path='/category' component={Category}/>
              <Route path='/product' component={Product}/>
              <Route path='/user' component={User}/>
              <Route path='/role' component={Role}/>
              <Route path="/charts/bar" component={Bar}/>
              <Route path="/charts/pie" component={Pie}/>
              <Route path="/charts/line" component={Line}/>
              <Redirect to='/home'/>
            </Switch>
          </Content>
          <Footer/>
        </Layout>
      </Layout>
    )
  }
}